/*
 * @Author: Evan-lian
 * @Date: 2023-12-25 16:41:18
 * @LastEditors: Evan-lian
 * @LastEditTime: 2023-12-25 16:58:32
 * @Description: 
 */
import { ReactNode } from 'react';
import {Navigate,useLocation} from 'react-router-dom';
//导入 ReactNode 类型
interface Iprops {
    children?:ReactNode
}
function Private(props:Iprops) {
    let location = useLocation();
    let token = sessionStorage.getItem('token')
    if(token){
        return <>{props.children}</>
    }else{
        return <Navigate to={`/?redirect=${location.pathname}`}></Navigate>
    }
}

export default Private;